home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / croutes.zip / SETPRTR.C < prev    next >
Text File  |  1984-07-29  |  5KB  |  287 lines

  1. /* --------------------------------------------------------------------- */
  2. /*    SETPRTR - Send printer setup codes to the IBM (MX-80) printer     */
  3. /*       Written for public domain distribution in             */
  4. /*       Caprock Systems Small-c:pc                     */
  5. /*       by    Michael Burton                         */
  6. /*        320 Highland Dr. Apt 203                 */
  7. /*        Glen Burnie, MD  21061                     */
  8. /*        (301)768-8358                         */
  9. /*                                     */
  10. /*    Version 1.0    09 May 1983                     */
  11. /* --------------------------------------------------------------------- */
  12.  
  13. #define CMPRSON     15    /* Compress code             */
  14. #define CMPRSOFF    146    /* Uncompress code             */
  15. #define DSOFF        200    /* Double strike off code         */
  16. #define ESC        27    /* Escape code                 */
  17. #define CR        13    /* Carriage return             */
  18. #define LF        10    /* Linefeed                 */
  19. #define BS        08    /* Backspace                 */
  20. #define TRUE        01
  21.  
  22. int cmd;
  23.  
  24. /* Beginning of SETPRTR main program    */
  25.  
  26. main()
  27. {
  28.     clrscreen();
  29.     putline("     IBM/EPSON MX-80 Printer Setup");
  30.     putline("            by Michael Burton ");
  31.     putline(" ");
  32.     putline("A] Double width on  L] Double width off");
  33.     putline("B] Compressed on    M] Compressed off");
  34.     putline("C] Underlining on   N] Underlining off");
  35.     putline("D] Emphasized on    P] Emphasized off");
  36.     putline("E] Doublestrike on  Q] Doublestrike off");
  37.     putline("F] Superscript on   R] Superscript off");
  38.     putline("G] Subscript on     S] Subscript off");
  39.     putline("H] Italics on       T] Italics off");
  40.     putline("I] Perf skip set    U] Perf skip off");
  41.     putline("J] Column width set V] Page length set");
  42.     putline("K] Printer reset    W] Return to DOS");
  43.  
  44.     while (TRUE)
  45.     {
  46.         putcurs(16,0);
  47.         puts("Selection?  ");
  48.         putchar(BS);
  49.         cmd = getchar() | 32;
  50.  
  51.         if (cmd == 'a')
  52.         {
  53.             prt3chr(ESC,'W',1);
  54.             finmes("Double Width Print on");
  55.         }
  56.         if (cmd == 'b')
  57.         {
  58.             prtchr(CMPRSON);
  59.             finmes("Compressed Print on");
  60.         }
  61.         if (cmd == 'c')
  62.         {
  63.             prt3chr(ESC,'-',1);
  64.             finmes("Underline on");
  65.         }
  66.         if (cmd == 'd')
  67.         {
  68.             prt2chr(ESC,'E');
  69.             finmes("Emphasized Print on");
  70.         }
  71.         if (cmd == 'e')
  72.         {
  73.             prt2chr(ESC,'G');
  74.             finmes("Double Strike Print on");
  75.         }
  76.         if (cmd == 'f')
  77.         {
  78.             prt3chr(ESC,'S',0);
  79.             finmes("Superscript on");
  80.         }
  81.         if (cmd == 'g')
  82.         {
  83.             prt3chr(ESC,'S',1);
  84.             finmes("Subscript on");
  85.         }
  86.         if (cmd == 'h')
  87.         {
  88.             prt2chr(ESC,'4');
  89.             finmes("Italics on");
  90.         }
  91.         if (cmd == 'i')
  92.         {
  93.     getinall("Perf skip how many lines? ",0,128,'N',"Perf skip set");
  94.         }
  95.         if (cmd == 'j')
  96.         {
  97.     getinall("No. of columns? ",0,232,'Q',"Column width set");
  98.         }
  99.         if (cmd == 'k')
  100.         {
  101.             prt2chr(ESC,'@');
  102.             finmes("Printer Reset");
  103.         }
  104.         if (cmd == 'l')
  105.         {
  106.             prt3chr(ESC,'W',0);
  107.             finmes("Double Width Print off");
  108.         }
  109.         if (cmd == 'm')
  110.         {
  111.             prtchr(CMPRSOFF);
  112.             finmes("Compressed Print off");
  113.         }
  114.         if (cmd == 'n')
  115.         {
  116.             prt3chr(ESC,'-',0);
  117.             finmes("Underline off");
  118.         }
  119.         if (cmd == 'p')
  120.         {
  121.             prt2chr(ESC,'F');
  122.             finmes("Emphasized Print off");
  123.         }
  124.         if (cmd == 'q')
  125.         {
  126.             prt2chr(ESC,DSOFF);
  127.             finmes("Double Strike Print off");
  128.         }
  129.         if (cmd == 'r')
  130.         {
  131.             prt2chr(ESC,DSOFF);
  132.             finmes("Superscript off");
  133.         }
  134.         if (cmd == 's')
  135.         {
  136.             prt2chr(ESC,DSOFF);
  137.             finmes("Subscript off");
  138.         }
  139.         if (cmd == 't')
  140.         {
  141.             prt2chr(ESC,'5');
  142.             finmes("Italics off");
  143.         }
  144.         if (cmd == 'u')
  145.         {
  146.             prt2chr(ESC,'O');
  147.             finmes("Perf skip off");
  148.         }
  149.         if (cmd == 'v')
  150.         {
  151.     getinall("How many lines? ",0,128,'C',"Page length set");
  152.         }
  153.         if (cmd == 'w') exit();
  154.         if (cmd == 'x') prtline();
  155.         if (cmd < 'a' | cmd > 'x')
  156.             bell();
  157.         else
  158.             delay(6000);
  159.     }
  160. }
  161.  
  162. /*  End of SETPRTR main program     */
  163. /*  Beginning of support functions    */
  164.  
  165. delay(n)    /* Wait a while */
  166.     int n;
  167. {
  168.     int i;
  169.  
  170.     i = 0;
  171.     while (i++ < n) {
  172.     }
  173.     while (i-- > 0) {
  174.     }
  175.     clearline(20);
  176. }
  177.  
  178. prtline()    /* Diagnostic. Print a line on the printer. */
  179. {
  180.     char buff[41];
  181.     int i;
  182.  
  183.     i = 0;
  184.     clearline(16);
  185.     putcurs(16,0);
  186.     gets(buff);
  187.     while (buff[i] >0)
  188.     {
  189.         pcdos(5,buff[i++]);
  190.     }
  191.     pcdos(5,CR);
  192.     pcdos(5,LF);
  193.     clearline(16);
  194. }
  195.  
  196. /*  Printer functions        */
  197.  
  198. getinall(s,l,u,c,t)
  199.     int *s,l,u,c,*t;
  200. {
  201.     int buff[41], n;
  202.  
  203.     while (TRUE)
  204.     {
  205.         clearline(16);
  206.         putcurs(16,0);
  207.         puts(s);
  208.         gets(buff);
  209.         n = atoi(buff);
  210.         clearline(16);
  211.         if (n <= l | n >= u)
  212.             bell();
  213.         else
  214.             break;
  215.     }
  216.     prt3chr(ESC,c,n);
  217.     finmes(t);
  218. }
  219. prt3chr(s,t,u)    /* Output 3 chars to the printer */
  220.     char s,t,u;
  221. {
  222.     prt2chr(s,t);
  223.     prtchr(u);
  224. }
  225.  
  226. prt2chr(s,t)    /* Output 2 chars to the printer */
  227.     char s,t;
  228. {
  229.     prtchr(s);
  230.     prtchr(t);
  231. }
  232.  
  233. prtchr(s)    /* Output a char to the printer */
  234.     char s;
  235. {
  236.     finmes("Ready Printer");
  237.     pcdos(5,s);
  238.     clearline(20);
  239. }
  240.  
  241. /* Display functions        */
  242.  
  243. putline(s)    /* Send a line to display with cr/lf */
  244.     char *s;
  245. {
  246.     puts(s);
  247.     putchar(CR);
  248. }
  249.  
  250. finmes(s)    /* Send a finish message to line 20 */
  251.     char *s;
  252. {
  253.     putcurs(20,0);
  254.     puts(s);
  255. }
  256.  
  257. clearline(n)    /* Clear 40 columns of line n */
  258.     int n;
  259. {
  260.     putcurs(n,0);
  261.     puts("                                       ");
  262. }
  263.  
  264. putcurs(r,c)    /* Put cursor at a specified row and column */
  265.     int r,c;
  266. {
  267.     int a,b,d;
  268.  
  269.     a = 2;
  270.     b = 0;
  271.     d = 0;
  272.     int10(a,d,b,d,d,d,r,c);
  273. }
  274.  
  275. atoi(s)     /* Convert a string to integer */
  276.     char *s;
  277. {
  278.     int n;
  279.     n = 0;
  280.     while (*s >= '0' && *s <= '9')
  281.     {
  282.         n = 10 * n + *s - '0';
  283.         s++;
  284.     }
  285.     return(n);
  286. }
  287.